<?php
include("gestione/includes/config.inc.php");
include("gestione/includes/auth.lib.php");
include("gestione/includes/function.inc.php");
include("gestione/includes/product_new.class.php");
include("gestione/includes/e-commerce_new.class.php");
include("gestione/includes/image.class.php");
include("gestione/includes/upload.class.php");
$rs = $conn->Execute("select idarticolo,codice from articoli_new where import=1 and giardino=1 and attivo='y' and image=''");
while(!$rs->EOF) {
	$codice = trim($rs->Fields("codice"));
	if(file_exists($_SERVER[DOCUMENT_ROOT]."/immagini-giardino/".$codice.".jpg")) {
	  $image = $_SERVER[DOCUMENT_ROOT]."/immagini-giardino/".$codice.".jpg";
	  $imagename = $codice.".jpg";
	  $image_gal = $codice."_6.jpg";
	} else if(file_exists($_SERVER[DOCUMENT_ROOT]."/immagini-giardino/".$codice.".png"))  {
	  $image = $_SERVER[DOCUMENT_ROOT]."/immagini-giardino/".$codice.".png";
	  $imagename = $codice.".png";
	  $image_gal = $codice."_6.png";
	} else 
	   $image = "";
	if($image!="") {
	$obj = new Image($image);
	$image2 = $imagename;
	$tmb = "tmb_".$image2;
	$big = "big_".$image2;
	$obj->SaveProportionateImage2($_SERVER['DOCUMENT_ROOT']."/immagini-giardino/".$image_gal, 80,0,$obj->src_width);
	if($obj->src_width > 200)
	$obj->SaveProportionateImage2($_SERVER['DOCUMENT_ROOT']."/immagini-giardino/".$big, 80,0,200);
	else
	$obj->SaveProportionateImage2($_SERVER['DOCUMENT_ROOT']."/immagini-giardino/".$big, 80,0,$obj->src_width);
	$obj->SaveProportionateImage2($_SERVER['DOCUMENT_ROOT']."/immagini-giardino/".$tmb, 60,0,40);
	$obj->SaveProportionateImage2($_SERVER['DOCUMENT_ROOT']."/immagini-giardino/".$image2, 60,0,80);
	$rs2 = $conn->Execute("UPDATE articoli_new SET image_tmb='$tmb',image='$image2',image_big='$big' WHERE idarticolo=".$rs->Fields("idarticolo").";");	
	if($rs2) echo $codice." ".$rs->Fields("titolo1")." --> ".$rs->Fields("idarticolo")."/".$rs->Fields("image")."<br>";
	}						
	$rs->MoveNext();
}
?>